package com.piece.core.framework.enums;

import com.piece.core.framework.util.collection.ArrayUtil;
import lombok.Getter;

/**
 * 选项类别
 */
@Getter
public enum OptionType {

    // 组
    GROUP("00", "group"),

    // 选项
    OPTION("01", "option"),

    // 短信
    SMS("0", "sms"),

    // 邮件
    MAIL("1", "mail"),

    // 消息
    MESSAGE("2", "message"),

    // 公告
    NOTICE("3", "notice"),

    // 任务
    TASK("4", "task"),

    // 叶子节点
    LEAF("Y", "leaf"),

    // 非叶子节点
    NOT_LEAF("N", "not_leaf");

    private final String code;
    private final String info;

    OptionType(String code, String info) {
        this.code = code;
        this.info = info;
    }

    public static OptionType getByCode(String code) {
        return ArrayUtil.firstMatch(o -> o.getCode().equals(code), values());
    }

    public static OptionType getByInfo(String info) {
        return ArrayUtil.firstMatch(o -> o.getInfo().equals(info), values());
    }
}
